Skip to content

The USB link from the shared emulink submodule - #25

Merged
finger563 merged 2 commits into
feat/remote-touchfrom
feat/emulink-submodule
Nov 16, 2026
Merged

finger563 merged 2 commits into
feat/remote-touchfrom
feat/emulink-submodule

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Stacked on the touch PR (#24); retarget to main once it merges. The same change is in the other emulator's repo (esp-cpp/esp-box-emu).

components/devlink, main/remote_control.hpp, tools/emulink and web/ were the same in esp-box-emu and tab5-emu. They now live in one place, esp-cpp/emulink, a submodule at components/emulink.

What changes here

  • Firmware: the emulink component replaces devlink in the component list. It contains DevLink and the header-only RemoteControl, which main includes with its own cart.hpp, gui.hpp and settings.hpp.
  • Board: the board component comes from idf_build_set_property(EMULINK_BOARD_COMPONENT ...), set before project(). It defaults to box-emu; the Tab5 sets tab5-emu.
  • Symlinks: tools/emulink and web are now links into the submodule, so cd tools/emulink && python -m emulink and python3 -m http.server -d web work as before.
  • Pages workflow: it fetches only the emulink submodule and publishes components/emulink/web. It now triggers on a change to the submodule's commit.

What the shared copy merged

  • Panic details: the box's extra panic details (cache errors, the faulting address). The Xtensa-only parts are guarded, so the same file builds for the P4.
  • Settings parsing: strtol instead of std::from_chars (one file for both).
  • Comments: the touch request's comment covers both boards.

Testing

  • Both emulators build.
  • Both boards were updated over the link with these builds.
  • Status, screenshots and a touch work on both boards afterwards.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

finger563 and others added 2 commits November 15, 2026 18:48
components/devlink, main/remote_control.hpp, tools/emulink and web/ were
the same in esp-box-emu and tab5-emu; they are esp-cpp/emulink now, a
submodule at components/emulink (the `emulink` component: DevLink and
the header-only RemoteControl). tools/emulink and web are links into it,
so `cd tools/emulink && python -m emulink` and the local web server work
as before; the pages workflow publishes components/emulink/web. The
board component comes from EMULINK_BOARD_COMPONENT (box-emu by default).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@finger563
finger563 merged commit 1f863aa into feat/remote-touch Nov 16, 2026
@finger563
finger563 deleted the feat/emulink-submodule branch November 16, 2026 02:33
finger563 added a commit that referenced this pull request Nov 16, 2026
…he shared emulink submodule (#24)

* Add the NES, Game Boy / Color, Master System / Game Gear, MSX, Doom and Dark Forces cores

The cores esp-box-emu moved to submodules (each repo holds the core plus
its port/ glue, written against BoxEmu, which the Tab5 aliases to
Tab5Emu), added the same way as the Genesis and PICO-8 ones:

- components/{nes,gbc,sms,msx,doom,darkforces}: the submodules plus their
  component CMake from the box, with the static state (.bss and .data)
  moved to PSRAM by tools/bss_to_psram.py (the P4 has no extern_ram
  placeholder for ldgen). fMSX and gnuboy define globals that snes9x, MGS,
  the Genesis core and the TPM runtime also define; those are renamed in
  their libraries with objcopy --redefine-syms.
- main/: the carts, ported from the box, with the Tab5's video settings
  (original = integer scale, fit, fill).
- rom_info: the new platforms (.nes, .gb, .gbc, .sms, .gg, .rom, .wad,
  DARK.GOB) and consoles (NES, Game Boy, Game Boy Color, Master System,
  Game Gear, MSX), in the box's order and colors.
- Tab5Emu: make_color(), osd_getromdata(), no-op haptics, and
  reserve_romdata(): MSX, Doom and Dark Forces run their allocator in the
  box's fixed 4 MB ROM block, which the Tab5 allocates per cart.
- pool_allocator from the box (JK's private pool functions are renamed
  jk_pool_* so they don't collide with it).

The core repos needed three RISC-V build fixes (fix/riscv-build in
esp-cpp/gnuboy, nofrendo and TheForceEngine): Xtensa-only inline asm and
an Xtensa-only ESP-IDF backtrace call.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* NES: full speed (nofrendo audio frame size fix)

The NES ran at ~30 fps: the glue made 1600 audio samples a frame instead
of 367, and the Tab5 paces to the DAC. Measured after the fix: ~3 ms of
emulation per frame, 60 emulated / ~30 presented fps (nofrendo's frame
skip).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* README: measured status of the new cores

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* ScummVM (Star Trek: 25th Anniversary): the core, its cart and platform

- components/scummvm: esp-cpp/scummvm (branch esp32p4) as a submodule, with
  the ESP32 backend in backends/platform/esp32; built with the startrek
  engine only, no RTTI and no ScummVM GUI (~1.1 MB of flash).
- A game is a marker file *.scummvm in the game's folder (Emulator::SCUMMVM,
  shown under PC); ScummVM detects which game the folder holds.
- ScummvmCart: the engine runs in its own task; the pause menu parks it and
  saves / loads through the engine's save states into the slot files; the
  4:3 games' 320x200 is shown at 4:3. Touch is the mouse (two fingers = right
  click), as are a USB mouse and the gamepad (A / B = left / right click).
- Tab5Emu::display_size() getter (touch -> game coordinates).
- CI: checks out the new core submodules (ScummVM shallow).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* ScummVM: Star Trek runs (saves, loads, quits); allocations in PSRAM

- esp-cpp/scummvm esp32p4 66a0f24: the backend's quit / load / task fixes
  and the startrek engine's save states and teardown fixes.
- The component renames ScummVM's allocation functions to the backend's
  PSRAM ones (backends/platform/esp32/psram_alloc.syms).

Tested on the Tab5 with the 25th Anniversary Enhanced CD (English + speech):
intro, bridge and briefings; pause-menu save (while the game waits for
input) and load (restarts the game with the state, from anywhere);
repeated launches and quits, including during the intro. Known: each engine
instance leaves ~90 KB of PSRAM behind (the engine's own teardown), until
the next boot.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* ScummVM: fix the PSRAM leaks (Star Trek), allocation tracker build option

- esp-cpp/scummvm esp32p4 7c81792: three startrek engine leaks fixed (LZSS
  input streams, the bridge's ever-growing action queue, the save
  thumbnail) and the backend's detection data left on a jumped-over stack.
- idf.py -DSCUMMVM_TRACK_ALLOCS=1 build: tracks ScummVM's allocations and
  writes what each run leaves to /sdcard/saves/scummvm_leaks.txt.

Measured on the Tab5: free PSRAM flat during bridge play (was -600 B/s), and
a few hundred bytes a game run (was 50-130 KB).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* Fix the games that ran out of memory after Dark Forces / Star Trek; Doom's crash

- Dark Forces: its free() wrapper kept claiming its ended session's 4 MB
  block, which the Tab5 gives back to the heap with the cart: every free()
  the other games later made into that range was swallowed, and Jedi Knight
  hung for want of memory. The cart now calls darkforces_forget_block()
  (TheForceEngine 03417ff) before the block goes.
- ScummVM (esp-cpp/scummvm a0a35c3): a game runs in its own PSRAM arena,
  given back whole at its end, and the long-lived set-up is done at boot
  (scummvm_prepare() in main): Star Trek no longer leaves blocks mid-heap
  that split the big ones Jedi Knight wants.
- Tab5Emu::play_audio()'s 30 s report is debug-level: it is formatted on the
  game's audio task, and Doom's 2 KB one overflowed (a stack protection
  fault after 30 s of play).

Checked on the Tab5: Doom (60+ s), Dark Forces, Star Trek, then Jedi Knight
(20 fps), MGS, TPM, GBA, Genesis, PICO-8, NES, GB/GBC, SMS/GG, MSX.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* JK: OpenJKDF2 fd47e34 (libsmacker double free when a 16-bit tree build fails late)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* JK, TPM: really free the per-session buffers (shrink_to_fit() is a no-op here)

Built without exceptions (ESP-IDF), libstdc++'s vector::shrink_to_fit()
does nothing: Jedi Knight's presentation buffers (~1.8 MB: the RGB565 frame,
two 8-bit frames, two overlays) and TPM's copy of the game executable stayed
allocated after the game. With ~1.35 MB less PSRAM since the new cores and
ScummVM, the SNES core then had too little left after Jedi Knight. They are
swapped with empty vectors now.

Checked on the Tab5: free PSRAM after quitting Jedi Knight is back to what
it was before (7.28 MB, largest block 7.17 MB); JK -> SNES -> TPM -> SNES ->
JK all run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* scummvm: Star Trek speech, intro stall and planet fixes

Bumps the esp-cpp/scummvm fork: config defaults registered (speech and
effects played at volume 0 once the engine synced its settings), repeated
log lines counted (the per-row drawR3Shape warning stalled the intro), close
shapes drawn and shapes behind the camera culled (the intro's planet).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* scummvm: Star Trek intro draws the Enterprise, planet and credits

Bumps the esp-cpp/scummvm fork to the reverse-engineered ship rendering
(views picked by angle, the original's 2D transform, dithered close-ups),
the view check and draw order, and the intro's movement, credits and
captions as the original plays them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* scummvm: Star Trek's viewscreen, planets, orbit and mission fly-bys

Bumps the esp-cpp/scummvm fork: the bridge's viewscreen shows space, the
star systems' planets (generated as the original does), entering and
leaving orbit and the mission start fly-bys as the original plays them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* ScummVM: star map and warp; the video setting once the screen's size is known

The ScummVM cart applied fit/original before the engine had set up its
screen (0x0 then, ScummVM being prepared at boot), so a game started
filling the screen until the pause menu re-applied it. It now follows the
screen's size whenever that changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* ScummVM: Star Trek's space combat and missions

Bumps the fork: ships fly and fight as the original's, the captain flies
and fires from the viewscreen (tap: phasers, two fingers: torpedoes), and
the missions' bridge scripts with their battles.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* ScummVM: Star Trek speed bars as a touch control

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* scummvm: ST25 intro credits and planet, speed bars let go

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* Touch over the USB link (emulink tap / touch / drag), touch as Dark Forces' mouse

The link's test control gets TOUCH (protocol 5): a finger at (x, y), held
for a time or until the next TOUCH, in the screen's pixels or (flag 0x80)
the screenshot's, which the firmware maps through the frame's place on
the screen. The finger counts as a touch everywhere: touchpad_data()
(ScummVM), the touch virtual gamepad and its menu hot corner, and the
launcher's LVGL menus (a pointer input device of its own).

emulink: tap, touch (hold / lift) and drag, --frame for screenshot
pixels. The web console's screen is a touch screen: click or drag on it.

Tab5Emu::touch_pointer() / screen_to_frame() give games a pointer that
can skip the touch gamepad's zones; Dark Forces (TheForceEngine
feat/touch-mouse) uses them: in the menus the finger is the cursor, in a
mission a drag off the touch gamepad is mouse look and a quick tap fires.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* Remote touch: hand LVGL the panel's coordinates

LVGL rotates what a pointer input device reads (the BSP's touch is the
panel's portrait coordinates), so the link's finger, in landscape, landed
elsewhere: rotate it back first.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* Remote touch: the cart for the frame's size is const (cppcheck constVariablePointer)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

* The USB link from the emulink submodule (#25)

components/devlink, main/remote_control.hpp, tools/emulink and web/ were
the same in esp-box-emu and tab5-emu; they are esp-cpp/emulink now, a
submodule at components/emulink (the `emulink` component: DevLink and
the header-only RemoteControl). tools/emulink and web are links into it,
so `cd tools/emulink && python -m emulink` and the local web server work
as before; the pages workflow publishes components/emulink/web. The
board component comes from EMULINK_BOARD_COMPONENT (box-emu by default).


Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* CI: check out the emulink submodule too

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant